Imports GeoFramework
Imports GeoFramework.Controls
Imports System.Drawing.Drawing2D
Imports System.Drawing.Text

Public Class ControlPerformanceTuningForm

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' Start receiving real-time GPS data
        GpsDevice.Start()

    End Sub

    Private Sub GlassEffectCheckBox_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GlassEffectCheckBox.CheckedChanged
        If GlassEffectCheckBox.Checked Then
            ' Enable the glass effect
            Altimeter.Effect = PolarControlEffect.Glass
            Compass.Effect = PolarControlEffect.Glass
            SatelliteViewer.Effect = PolarControlEffect.Glass
            Speedometer.Effect = PolarControlEffect.Glass
        Else
            ' Use no effect
            Altimeter.Effect = PolarControlEffect.None
            Compass.Effect = PolarControlEffect.None
            SatelliteViewer.Effect = PolarControlEffect.None
            Speedometer.Effect = PolarControlEffect.None
        End If
    End Sub

    Private Sub SmoothingCheckBox_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles SmoothingCheckBox.CheckedChanged
        If SmoothingCheckBox.Checked Then
            ' Enable the glass effect
            Altimeter.SmoothingMode = SmoothingMode.HighQuality
            Compass.SmoothingMode = SmoothingMode.HighQuality
            SatelliteViewer.SmoothingMode = SmoothingMode.HighQuality
            Speedometer.SmoothingMode = SmoothingMode.HighQuality
        Else
            ' Use no effect
            Altimeter.SmoothingMode = SmoothingMode.HighSpeed
            Compass.SmoothingMode = SmoothingMode.HighSpeed
            SatelliteViewer.SmoothingMode = SmoothingMode.HighSpeed
            Speedometer.SmoothingMode = SmoothingMode.HighSpeed
        End If
    End Sub

    Private Sub TextSmoothingCheckBox_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextSmoothingCheckBox.CheckedChanged
        If TextSmoothingCheckBox.Checked Then
            ' Enable text smoothing
            Altimeter.TextRenderingHint = TextRenderingHint.AntiAlias
            Compass.TextRenderingHint = TextRenderingHint.AntiAlias
            SatelliteViewer.TextRenderingHint = TextRenderingHint.AntiAlias
            Speedometer.TextRenderingHint = TextRenderingHint.AntiAlias
        Else
            ' Use no text smoothing effects
            Altimeter.TextRenderingHint = TextRenderingHint.SingleBitPerPixel
            Compass.TextRenderingHint = TextRenderingHint.SingleBitPerPixel
            SatelliteViewer.TextRenderingHint = TextRenderingHint.SingleBitPerPixel
            Speedometer.TextRenderingHint = TextRenderingHint.SingleBitPerPixel
        End If
    End Sub

    Private Sub SeparateThreadCheckBox_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles SeparateThreadCheckBox.CheckedChanged
        If SeparateThreadCheckBox.Checked Then
            ' Launch rendering on their own thread
            Altimeter.IsPaintingOnSeparateThread = True
            Compass.IsPaintingOnSeparateThread = True
            SatelliteViewer.IsPaintingOnSeparateThread = True
            Speedometer.IsPaintingOnSeparateThread = True
        Else
            ' Shut down any rendering threads
            Altimeter.IsPaintingOnSeparateThread = False
            Compass.IsPaintingOnSeparateThread = False
            SatelliteViewer.IsPaintingOnSeparateThread = False
            Speedometer.IsPaintingOnSeparateThread = False
        End If
    End Sub

    Private Sub ValueInterpolationCheckBox_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ValueInterpolationCheckBox.CheckedChanged
        If ValueInterpolationCheckBox.Checked Then
            ' Use smooth interpolation when values change
            Altimeter.ValueInterpolationMethod = InterpolationMethod.CubicEaseInOut
            Compass.ValueInterpolationMethod = InterpolationMethod.CubicEaseInOut
            Speedometer.ValueInterpolationMethod = InterpolationMethod.CubicEaseInOut

            Altimeter.RotationInterpolationMethod = InterpolationMethod.CubicEaseInOut
            Compass.RotationInterpolationMethod = InterpolationMethod.CubicEaseInOut
            SatelliteViewer.RotationInterpolationMethod = InterpolationMethod.CubicEaseInOut
            Speedometer.RotationInterpolationMethod = InterpolationMethod.CubicEaseInOut
        Else
            ' Use no interpolation
            Altimeter.ValueInterpolationMethod = InterpolationMethod.Snap
            Compass.ValueInterpolationMethod = InterpolationMethod.Snap
            Speedometer.ValueInterpolationMethod = InterpolationMethod.Snap

            Altimeter.RotationInterpolationMethod = InterpolationMethod.Snap
            Compass.RotationInterpolationMethod = InterpolationMethod.Snap
            SatelliteViewer.RotationInterpolationMethod = InterpolationMethod.Snap
            Speedometer.RotationInterpolationMethod = InterpolationMethod.Snap
        End If
    End Sub

    Private Sub FrameRateTrackBar_Scroll(ByVal sender As Object, ByVal e As EventArgs) Handles FrameRateTrackBar.Scroll
        ' Change the smoothness of animations for the controls
        Altimeter.TargetFramesPerSecond = FrameRateTrackBar.Value
        Compass.TargetFramesPerSecond = FrameRateTrackBar.Value
        SatelliteViewer.TargetFramesPerSecond = FrameRateTrackBar.Value
        Speedometer.TargetFramesPerSecond = FrameRateTrackBar.Value
    End Sub

End Class